<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var  date1 = new Date();
    var  year = date1.getFullYear();
    console.log(year);
    //获取的月份的取值范围 0~11
    var month = date1.getMonth();
    month =month+1;
    console.log(month);
//获取星期  日期对象   .getDay();
//获取星期的取值范围 0~6，
//每个星期的第一天是星期日
    var weeks =["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]
    var weekday =date1.getDay();
    console.log(weekday);
    console.log(weeks[weekday]);
//getdate  获取今天的日期
    var day = date1.getDate();

    var hour = date1.getHours();
    var minute =date1.getMinutes();
    var sec = date1.getSeconds();
    </script>
</html>